<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            margin: 0;
            padding: 0;
            background-color: #222;
        }
        #container{
            width: 300px;
            padding-top: 10vw;
            margin: 0 auto;
            margin-top: 2em;
            color: #fff;
            text-align: center;
            position: relative;
        }

        .text{
            position: absolute;
            top: 0;
            left: 30%;
            font-size: 30px;
            color: red;
        }

        #sum{
            font-size: 30px;
            font-weight: bold;
            color: #fff;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%,-50%);
            font-size: 30px;
        }

        #line{
            width: 0;
            height: 2px;
            background-color: red;
            position: absolute;
            bottom: 0;
            left: 0;
        }
    </style>
</head>
<body>
    <div id="container">
        <div class="text">Loading</div>
        <div id="sum">0%</div>
        <div id="line"></div>
    </div>
</body>
</html>

<script>
    var sum = 0;
    var sumEle = document.getElementById('sum');
    var line = document.getElementById('line');
    var timer = setInterval(function(){
        sum++;
        sumEle.innerHTML = sum + '%';
        line.style.width = sum + '%';
        if(sum == 100){
            sum = 0;
            // clearInterval(timer);
            // document.getElementById('container').innerHTML = '加载完成';
        }
    },100);
</script>